<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Recapcha
 *
 * @author Windy
 */
require_once('recapcha/recaptchalib.php');

class Rabbit_Recapcha {
    const PRIVATE_KEY = '6LdHatASAAAAAJJslxrKXpj-qNY8pasBtx8_HiOX ';

    static  $_error;

    /**
     * Check capcha posted
     * @param string $recaptcha_challenge_field
     * @param string $recaptcha_response_field
     */
    public static function checkCapcha($recaptcha_challenge_field, $recaptcha_response_field) {
        $resp = recaptcha_check_answer(self::PRIVATE_KEY,
                        $_SERVER["REMOTE_ADDR"],
                        $recaptcha_challenge_field,
                        $recaptcha_response_field);

        if (!$resp->is_valid) {
            self::$_error = $resp->error;
            return false;
        } else {
            return true;
        }
    }
    public static function getError(){
        return self::$_error;
    }

}

?>
